# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Juergen Hoetzel <juergen@archlinux.org>
# Contributor: Paulius Palevicius <paulius@birzai.com>

pkgname=catdoc
pkgver=0.95
pkgrel=5
pkgdesc='A convertor for Microsoft Word, Excel, PowerPoint and RTF Files to text'
arch=('loong64' 'x86_64')
url='https://www.wagner.pp.ru/~vitus/software/catdoc/'
license=('GPL')
depends=('glibc')
optdepends=('tk: for using wordview')
options=('!makeflags')
source=(
  "http://ftp.wagner.pp.ru/pub/catdoc/catdoc-$pkgver.tar.gz"
  "$pkgname-read-boolean-values.patch::https://github.com/albfan/catdoc/commit/101a9775ca3620f4a307a1159a41777115e8a04d.patch"
  "$pkgname-explicit-errors.patch::https://github.com/albfan/catdoc/commit/3613753da4cc47331f0cebd49445da357b8b5f75.patch"
) 
sha512sums=('dd6bded4b6b70749c007256b182b063ff266f86d53024d8582001678821e8096c5b980bc8f43015d9c82bbe022d71d4ba5fe68aff31b2ff6db3688595e651b2c'
            'cf7d4132ef52df9d102c183efa1707aa78ca6bb692e3d48b621eb0f8e509be2789b83507e8975ddc216766aff31d0877d524791755b81c7a8a7ffec568956fda'
            'd85aa9fdb44525573df98f9d2e6b89d69f5f7a3708e5113f1378fbf6d56a7599c49279cd19e52664f276fb730e498bd37ef56d2f96a29f1de16c7001608be991')
b2sums=('37c01c485410a6eb08c5935351b00f60f1d4c418f4c1b3cca73da23f870cb5d5414ea6cf7c37effb295e6ccb12a7981367bd08ca6226ee0fc64d2dfdca2762ea'
        '18f0c07d83174084bb27e3e47c35c14438403cd15ca89808495c4b696abfef3997b8d1cc349ff9c64e28bbaa92030a03f7b9981009e41f2b20acca2c88fcac44'
        'c74123d4ba8911ccc6ab6c904eb428756559cd1dc7804803665bbe26b745796142fb272c58a0bf94a52724ee375d37f9514a7026fd13e5a373afe552503fca31')

prepare() {
  cd "$pkgname-$pkgver"

  patch -p1 -i "$srcdir/$pkgname-read-boolean-values.patch"
  patch -p1 -i "$srcdir/$pkgname-explicit-errors.patch"
}

build() {
  cd "$pkgname-$pkgver"

  ./configure \
    --prefix=/usr  \
    --with-wish=/usr/bin/wish

  make
}

package() {
  cd "$pkgname-$pkgver"

  make installroot="$pkgdir" mandir=/usr/share/man/man1 install

  # man pages
  install -vDm644 -t "$pkgdir/usr/share/man/man1" doc/*.1
}
